<template>
		<el-form :model="ruleForm" size="large" label-width="100px" ref="formRef">
			<el-row :gutter="35">
				<el-col  :lg="24"   class="mb20">
					<el-form-item label="企业页面内容"   prop="Content">
					 <Editor :is-disable="false" v-model="ruleForm.Content" />
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="35">
				<el-col  :lg="12"  :offset="12" class="mb20">
					<span class="dialog-footer">
						<el-button type="primary" @click="onSubmit(formRef)" size="large"> 保存 </el-button>
					</span>
				</el-col>
				
			</el-row>
		
		</el-form>
</template>

<script lang="ts">
	import {
		toRefs,
		reactive,
		onMounted,
		ref
	} from 'vue';
	import { usePageApis } from '/@/api/EnterprisePageSettings/index';
	import {
		ElMessageBox,
		ElMessage
	} from 'element-plus';
	 
import Editor from '/@/components/editor/index.vue';
	import {
		deepClone
	} from '/@/utils/other';
	export default {
		name: '',
		components: {
			 Editor
		},
		
		setup() {
			const APIList=usePageApis();
			 const formRef=ref();
			const state: any = reactive({
				 ruleForm:{
					 Content:''
					 
				 }
			});
			onMounted(() => {
				loadData();
			});
			 
			const loadData = () => {
			 
				APIList.getModelAPI({}).then(async (response) => {
					//console.log(response);
					if (response.code === 0) {
					 state.ruleForm=response.result;
					}

				}).finally(() => {
					 
				});
			};
			 const onSubmit = (formEl: FormInstance | undefined) => {
			 	//console.log('submit!')
			 	if (!formEl) return
			 	formEl.validate((valid) => {
			 		if (valid) {
			 			//	console.log('submit!')
			 
			 			 
			 			APIList.saveModelAPI(state.ruleForm).then(async (response) => {
			 				//console.log(response);
			 				if (response['code'] === 0) {
			 					 
			 					ElMessage.success(`${response.message}`);
			 					 
			 				}
			 
			 
			 			});
			 		} else {
			 
			 			return false
			 		}
			 	})
			 };
			 
			 
			return {
				 formRef,
				...toRefs(state),
				 onSubmit,
			};
		 }
	};
</script>
 

<style>
</style>